package com.haizhi.crm.api.controller.tag;

import com.haizhi.crm.api.constant.MediaType;
import com.haizhi.crm.common.model.PageResponse;
import com.haizhi.crm.common.model.Response;
import com.haizhi.crm.tag.model.TagPageQo;
import com.haizhi.crm.tag.model.TagQo;
import com.haizhi.crm.tag.service.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by chengmo on 2018/5/18.
 */
@Api(description = "[标签#模块二级]标签增删改查" )
@RestController
@RequestMapping("/tag" )
public class TagController {

    @Autowired
    private TagService tagService;

    @ApiOperation(value = "获取多个企业标签列表", notes = "输入 {\"graph\": \"crm_dev2\",\"objectKeys\": [],\"tagIds\": []}" )
    @GetMapping("/findByObjectKeys" )
    public Response findByObjectKeys(@ModelAttribute TagQo tagQo) {
        return tagService.findByObjectKeys(tagQo);
    }

    @ApiOperation(value = "分页查询标签", notes = "无" )
    @GetMapping("/findPage" )
    public PageResponse findPage(@ModelAttribute TagPageQo tagPageQo) {
        return tagService.findPage(tagPageQo);
    }

    @ApiOperation(value = "获取单个标签", notes = "输入 {\"tagId\": 1}" )
    @GetMapping("/get" )
    public Response get(@ModelAttribute TagQo tagQo) {
        return tagService.get(tagQo);
    }

    @ApiOperation(value = "保存标签", notes = "待补充" )
    @PostMapping(path = "/save", consumes = MediaType.APP_JSON, produces = MediaType.APP_JSON)
    public Response save(@RequestBody TagQo tagQo) {
        return tagService.save(tagQo);
    }

    @ApiOperation(value = "修改标签", notes = "待补充" )
    @PostMapping(path = "/update", consumes = MediaType.APP_JSON, produces = MediaType.APP_JSON)
    public Response update(@RequestBody TagQo tagQo) {
        return tagService.update(tagQo);
    }

    @ApiOperation(value = "删除标签", notes = "输入 {\"tagId\": 1}" )
    @DeleteMapping(path = "/delete" )
    public Response delete(@ModelAttribute TagQo tagQo) {
        return tagService.delete(tagQo);
    }
}
